package com.example.service.impl;

import com.example.dao.BookDao;
import com.example.domain.Book;
import com.example.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class BookServiceimpl implements BookService {
    @Autowired
    private BookDao bookDao;

    @Override
    public List<Book> getAll() {
        return bookDao.getAll();
    }

    @Override
    public Book findbyid(Integer id) {
        /*if(id==1){
            throw new BusinessException(Code.BUSINESS_ERR,"请不要使用你的技术来挑战我的耐性！");
        }*/
        return bookDao.findbyid(id);
    }

    @Override
    public boolean insert(Book book) {
        bookDao.insert(book);
        return true;
    }

    @Override
    public boolean update(Book book) {
        bookDao.update(book);
        return true;
    }

    @Override
    public boolean delete(Integer id) {
        bookDao.delete(id);
        return true;
    }
}
